package cn.com.lyj6851.sso.service;

import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

@Component
@Slf4j
public class SsoUserDetailsService implements UserDetailsService {
    //Logger logger = LoggerFactory.getLogger(getClass());

   

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        String password = PasswordEncoderFactories.createDelegatingPasswordEncoder().encode("123456");
        log.info("用户名 {}，数据库密码{}", username, password);
        User admin = new User(username,
//                              "{noop}123456",
                password,
                true, true, true, true,
                AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER"));
        return admin;
    }
}
